from mediator import mediator
from mediator . tests . test_assistant import make_mediator_test_keyword_args

class welcome_logic_fake :
    def __init__ ( self ) :
        self . _show_welcome = False
        self . _hide_welcome = False
        self . _mouse_button_1_pressed = False
        self . _any_key_pressed = False
        self . _key_up_pressed = False
        self . _key_down_pressed = False
        self . _key_escape_pressed = False
    def show_welcome ( self ) :
        self . _show_welcome = True
    def hide_welcome ( self ) :
        self . _hide_welcome = True
    def on_mouse_button_1 ( self ) :
        self . _mouse_button_1_pressed = True
    def on_any_key ( self ) :
        self . _any_key_pressed = True
    def on_key_up ( self ) :
        self . _key_up_pressed = True
    def on_key_down ( self ) :
        self . _key_down_pressed = True
    def on_key_return ( self ) :
        mediator_welcome_logic_tests . _call_history += [ welcome_logic_fake . on_key_return ]
    def on_key_escape ( self ) :
        self . _key_escape_pressed = True

class arbitrary_module_fake :
    def show_welcome ( self ) :
        pass
    def hide_welcome ( self ) :
        pass
    def on_key_return ( self ) :
        mediator_welcome_logic_tests . _call_history += [ arbitrary_module_fake . on_key_return ]
    def on_key_up ( self ) :
        pass
    def on_key_escape ( self ) :
        pass
    def on_key_down ( self ) :
        pass
    def on_any_key ( self ) :
        pass

class mediator_welcome_logic_tests : 
    'mediator_welcome_logic'
    def __init__ ( self , test ) :
        mediator_welcome_logic_tests . _call_history = [ ]
        self . _test = test
        self . _welcome_logic = welcome_logic_fake ( )
        self . _mediator = mediator ( )
        self . _mediator . register_modules ( ** make_mediator_test_keyword_args \
            ( 'welcome_logic' 
            , self . _welcome_logic
            , arbitrary_module_fake
            ) )
    def test_show_welcome ( self ) :
        self . _mediator . show_welcome ( )
        self . _test . assume_true ( self . _welcome_logic . _show_welcome )
    def test_hide_welcome ( self ) :
        self . _mediator . hide_welcome ( )
        self . _test . assume_true ( self . _welcome_logic . _hide_welcome )
    def test_on_key_up ( self ) :
        self . _mediator . on_key_up ( )
        self . _test . assume_true ( self . _welcome_logic . _key_up_pressed )
    def test_on_key_escape ( self ) :
        self . _mediator . on_key_escape ( )
        self . _test . assume_true ( self . _welcome_logic . _key_escape_pressed )
    def test_on_key_return ( self ) :
        self . _mediator . on_key_return ( )
        self . _test . assume_equal ( mediator_welcome_logic_tests . _call_history [ 0 ] , welcome_logic_fake . on_key_return )    
    def test_on_key_down ( self ) :
        self . _mediator . on_key_down ( )
        self . _test . assume_true ( self . _welcome_logic . _key_down_pressed )
    def test_on_mouse_button_1 ( self ) :
        self . _mediator . on_mouse_button_1 ( )
        self . _test . assume_true ( self . _welcome_logic . _mouse_button_1_pressed )
    def test_on_any_key ( self ) :
        self . _mediator . on_any_key ( )
        self . _test . assume_true ( self . _welcome_logic . _any_key_pressed )
